<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Insert title here</title>
        <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/dataTables.bootstrap.min.css">
        <link rel="stylesheet" type="text/css" media="screen" href="../../global/layui/css/modules/laydate/default/laydate.css"/>
        <link rel="stylesheet" type="text/css" media="screen" href="../../global/layui/css/layui.css">
    </head>
    <body>
    <div>
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <header style="height: 100%">
                <div align="left">
                    <table style="width: 100%">
                        <tr>
                            <td>
                                <form class="form-inline" onsubmit="return false">
                                    <div class="form-group">
                                        <br>
                                        流水号:
                                        <input id="tradeNo" type="text" class="form-control" placeholder="订单编号">
                                        申请时间:
                                        <input id="startTime" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss">
                                        <span>~</span>
                                        <input id="endTime" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss">
                                        提现进度:
                                        <select id="status" class="form-control">
                                            <option selected="selected" value="0">请选择</option>
                                            <option value="1">已到账</option>
                                            <option value="2">未到账</option>
                                        </select>
                                        <button id="searchBt" class="layui-btn layui-btn-sm" ><i
                                                class="layui-icon">&#xe615;</i>搜索
                                        </button>
                                    </div>
                                </form>
                            </td>
                        </tr>
                    </table>
                </div>
            </header>
            <br>
            <br>
            <div>
                <div class="widget-body no-padding">
                    <table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
                        <thead>
                        <tr>
                        </tr>
                        <tr>
                            <th width="10%">流水号</th>
                            <th width="10%">申请时间</th>
                            <th width="10%">提现金额</th>
                            <th width="10%">税费扣除</th>
                            <th width="10%">提现卡号</th>
                            <th width="10%">提现进度</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    </body>
</html>

<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<!--<script type="text/javascript" src="../../global/js/dict.js"></script>-->
<script type="text/javascript" src="../../global/layui/lay/modules/laydate.js"></script>
<script type="text/javascript" src="../../global/layui/lay/modules/layer.js"></script>
<script type="text/javascript" src="../../global/js/my/permission.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript">

    var startTime ="";
    var endTime = "";
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#startTime', //指定元素
            type:"datetime",
            done:function (value, date, endDate) {
                startTime = value;
            }
        });
        laydate.render({
            elem: '#endTime', //指定元素
            type:"datetime",
            done:function (value, date, endDate) {
                endTime = value;
            }
        });
    });

    var layer ;
    layui.use('layer', function () {
        layer = layui.layer;
    });

    var example;

    function init() {
        example =
            $('#dt-table').DataTable({
                "searching": false,
                "processing": false,
                "serverSide": true,
                "retrieve":true,
                "destroy":true, //Cannot reinitialise DataTable,解决重新加载表格内容问题
                "language": {
                    "url": "/global/js/plugin/datatables/Chinese.lang"
                },
                "ajax": {
                    "url": "/clyjShopProperty/selectWithdrawalRecord",
                    "type": "get",
                    "data": function (d) {
                        d.tradeNo = $('#tradeNo').val();
                        var status = $('#status option:selected').val();
                        d.state = (status == 0 ? "" : status);
                        d.startTime = startTime;
                        d.endTime = endTime;
                        d.flag = 2;
                    },
                    "error": function (xhr, textStatus, errorThrown) {
                        var msg = xhr.responseText;
                        var response = JSON.parse(msg);
                        var code = response.code;
                        var message = response.message;
                        if (code == 400) {
                            layer.msg(message);
                        } else if (code == 401) {
                            localStorage.removeItem("token");
                            layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
                                location.href = '/login.html';
                            });
                        } else if (code == 403) {
                            console.log("未授权:" + message);
                            layer.msg('未授权');
                        } else if (code == 500) {
                            layer.msg('系统错误:' + message);
                        }
                    }
                },
                "dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
                "columns": [
                    {"data": "tradeNo", "defaultContent": ""},
                    {"data": "createTime","defaultContent": ""},
                    {"data": "value", "defaultContent": ""},
                    {"data": "value", "defaultContent": ""},
                    {"data": "cardNo", "defaultContent": ""},
                    {"data": "state","defaultContent": ""},
                ],
                "order": [[2, "desc"]]
            });

    };

    layui.use('layer', function () {
        var layer = layui.layer;
    });

    function initData() {
        $.ajax({
            url: '/clyjUserProperty/queryUserProperty',
            contentType: "application/json",
            type: 'post',
            dataType:"json",
            data:JSON.stringify({
                "token":window.localStorage.getItem('token')
            }),
            success: function (result) {
                var data = result.data;
                if(result.code == "success"){
                    $("#accountBalance").text(data==null?0:data.account);
                    $("#blockedBalance").text(data==null?0:data.freezeAccount+data.freezePayAccount);
                    init();
                }else {
                    layer.msg(result.message())
                }
            }
        });
    };

    $(function(){
        initData();
    });

    $("#searchBt").click(function () {
        example.ajax.reload();

    });

</script>